class Solution {
    public boolean isSameTree(TreeNode root,TreeNode subRoot) {
        if(root!=null && subRoot==null) {
            return false;
        }
        if(root==null && subRoot!=null) {
            return false;
        }
        if(root==null) {
            return true;
        }
        if(root.val != subRoot.val) {
            return false;
        }
        return isSameTree(root.right,subRoot.right) && isSameTree(root.left,subRoot.left);
    }
    public boolean isSubtree(TreeNode root, TreeNode subRoot) {
        if(root==null) return false;
        if(isSameTree(root,subRoot)) return true;
        if(isSameTree(root.left,subRoot)) return true;
        if(isSameTree(root.right,subRoot)) return true;
        return false;
    }
}
public class lc572 {
}
